package com.gimi.cloud.mmf.gateway.common.enums;


/**
 * 返回代码状态
 *
 */
public enum ResponseCodeEnum {
    /*
     *
     */
    INVALID("-1", "无效状态"),
    SUCCESSED("0000", "操作成功"),
    PROMPT_ERROR("0100", ""), //需要返回参数的异常
    USER_EXISTENCE("0001", "用户已存在"),
    ERR_BUSINESS("0002","业务级别的错误"),
    ERR_USER_INVALID("0201","用户不存在"),
    PARAMETER_ERROR("1000", "参数错误"),
    DATA_ERROR("2000", "数据错误"),
    ERRORED("2001","插入数据失败"),
    NETWORK_ERROR("3000", "网络错误"),
    MESSAGE_ERROR("4000", "报文错误"),
    ACCOUNTID_NOTFOUND("4001", "帐号不存在"),
    SIGNATURE_ERROR("4002", "请重新登录"),
    SIGNATURE_TIMEOUT("4003", "令牌过期"),
    USERPASSWORD_ERROR("4004","密码错误"),
    API_ERROR("4005", "该API暂未开通请联系管理员"),
    SALT_ERROR("4006","salt错误，请确认"),
    ACCESS_BARRED_ERROR("0403","流程级别的错误"),
    UNKNOWN_ERROR("9000", "未知错误"),
    SERVICENAME_NOTFOUND("9010", "服务名称错误或尚未提供指定服务"),
    APINAME_NOTFOUND("9020","API名称错误或尚未提供指定"),
    ASK_FOR_ERROR("0403","申请失败"),
    USER_STATUS_ERROR("3100","用户状态错误"),
    LOGIN_REPEAT_ERROR("4007","您的账号在其他机器登录");
	

    /**
     * 状态值
     */
    private String status;

    /**
     * 状态描述
     */
    private String desc;

    private ResponseCodeEnum(String status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public String getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据状态值获取枚举值
     *
     * @param status
     * @return
     */
    public static ResponseCodeEnum getStatus(String status) {
        for (ResponseCodeEnum e : ResponseCodeEnum.values()) {
            if (e.getStatus() == status) {
                return e;
            }
        }

        return INVALID;
    }

    /**
     * 根据状态值获取枚举值
     *
     * @param status
     * @return
     */
    public static ResponseCodeEnum getStatus(Integer status) {
        return status==null ? INVALID : getStatus(status.intValue());
    }

}